<template>
  <div id="app">
    <el-container>
      <!-- tou  -->
      <el-header>
        <el-row>
          <el-col :span="4"
            ><div class="grid-content bg-purple">logo</div></el-col
          >
          <el-col :span="16"
            ><div class="grid-content bg-purple-light">
              公司后台管理
            </div></el-col
          >
          <el-col :span="4"
            ><div class="grid-content bg-purple">
              <el-button type="info" @click="info"> 退出</el-button>
            </div></el-col
          >
        </el-row>
      </el-header>
      <el-container>
        <el-aside :width="isCollapse ? '65px' : '200px'">
          <!-- 侧 -->
          <div @click="isCollapse = !isCollapse">
            <p :class="isCollapse ? 'active' : ''">|||</p>
          </div>
          <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            background-color="#323642"
            text-color="#fff"
            active-text-color="#409eff"
            :unique-opened="true"
            router
            :collapse="isCollapse"
          >
            <el-submenu
              :index="item.id + ''"
              v-for="(item, index) in list"
              :key="index"
            >
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{ item.authName }}</span>
              </template>
              <el-menu-item-group>
                <el-menu-item
                  :index="'/' + ele.path"
                  v-for="(ele, inn) in item.children"
                  :key="inn"
                >
                  <i class="el-icon-menu"></i>
                  <span slot="title">{{ ele.authName }}{{ ele.path }}</span>
                </el-menu-item></el-menu-item-group
              >
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import { AsidApi } from '@/http/api'
export default {
  name: 'homeA',
  data() {
    return {
      list: [],
      isCollapse: false
    }
  },
  created() {
    this.getasid()
  },
  methods: {
    async getasid() {
      const res = await AsidApi()
      console.log('asid', res)
      this.list = res
    },
    info() {
      sessionStorage.removeItem('token')
      this.$router.push('/login')
    }
  }
}
</script>
<style lang="scss" scoped>
.el-container {
  height: 100%;
}
.el-header {
  background-color: #323642;
  color: rgb(254, 254, 254);
  text-align: center;
  line-height: 60px;
  padding: 0 0;
}

.el-aside {
  background-color: #323642;
  color: rgb(255, 255, 255);
  div {
    cursor: pointer;
    background-color: #495062;
    line-height: 30px;
    height: 30px;
    text-align: center;
  }
  transition: 0.3s all linear;
  .active {
    transform: rotate(-90deg);
  }
}
.el-submenu,.el-menu-item{
  // min-width: none;
  border-right: none;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
}

body > .el-container {
  margin-bottom: 40px;
}
</style>
